import { createRouter, createWebHashHistory, createWebHistory, createMemoryHistory } from 'vue-router'

import DeliverySystem from '../pages/DeliverySystem.vue'
import LoginView from '../pages/LoginView.vue'
import Error404 from '../pages/Error404.vue'

export const routes = [
  {
    path: '/', redirect: '/login'//, meta: { show: false }
  },
  {
    path: '/login',
    component: LoginView,
    meta: { title: '登录', auth: false, keepAlive: true },
  },
  {
    path: '/home',
    component: DeliverySystem,
    meta: { title: '后台首页', auth: true, keepAlive: false },
    redirect: '/home/backstage',
    children: [
      { path: '/home/backstage', component: () => import('../pages/BackstageHome.vue'), },//后台首页// 路由懒加载
      { path: '/home/order/manage', component: () => import('../pages/order/OrderManage.vue'), },// 订单管理
      { path: '/home/order/Edit', component: () => import('../pages/order/OrderEdit.vue'), },// 订单编辑
      { path: '/home/goods/List', component: () => import('../pages/goods/GoodsList.vue'), },// 商品列表
      { path: '/home/goods/add', component: () => import('../pages/goods/GoodsAdd.vue'), },// 商品添加
      { path: '/home/goods/Type', component: () => import('../pages/goods/GoodsType.vue'), },// 商品分类
      { path: '/home/shop/manage', component: () => import('../pages/shop/StoreManagement.vue'), },// 店铺管理
      { path: '/home/account/list', component: () => import('../pages/account/AccountList.vue'), },// 账号列表
      { path: '/home/account/add', component: () => import('../pages/account/AccountAdd.vue'), },// 账号添加
      { path: '/home/account/Password', component: () => import('../pages/account/ChangePassword.vue'), },// 修改密码
      { path: '/home/account/Personal', component: () => import('../pages/account/PersonalCenter.vue'), },// 个人中心
      { path: '/home/statistics/Product', component: () => import('../pages/statistics/StatisticsProduct.vue'), },//商品统计
      { path: '/home/statistics/Order', component: () => import('../pages/statistics/StatisticsOrder.vue'), },//订单统计
    ]
  },
  { path: '/:pathMatch(.*)*', component: Error404, meta: { show: false } } // 这是404页面的路由
]
const router = createRouter({
  // history: createWebHashHistory(), // 路由模式，hash模式、history模式、memory模式
  history: createWebHistory(), // 历史模式
  routes // 路由中url和组件一一对应的映射数组
})
export default router